package dongshi.daddy.adaptive.useinsubcls;

import com.alibaba.dubbo.common.extension.ExtensionLoader;
import org.junit.Test;

public class AdaptiveInSubClsTest {
    @Test
    public void testGetExtensionLoader() {
        System.out.println("111");
        ExtensionLoader<UseInSubClsInterface> extensionLoader = ExtensionLoader
                .getExtensionLoader(UseInSubClsInterface.class);
        UseInSubClsInterface useInSubClsInterface
                = extensionLoader
                // 获取Aaptive的子类
                .getAdaptiveExtension();
        useInSubClsInterface.sayHi("good night,mongo need to drink milk!!!");
    }

    @Test
    public void testLoadExtensionClasses() {
        System.out.println("222");
        ExtensionLoader<UseInSubClsInterface> extensionLoader = ExtensionLoader
                .getExtensionLoader(UseInSubClsInterface.class);
        extensionLoader.hasExtension("concreteUseInSubClsInterface1");
        extensionLoader.hasExtension("adaptive");

    }
    @Test
    public void testInjectExtensionClasses() {
        System.out.println("333");
        ExtensionLoader<UseInSubClsInterface> extensionLoader = ExtensionLoader
                .getExtensionLoader(UseInSubClsInterface.class);
        // 内部会自动调用injectExtension注入属性
        UseInSubClsInterface concreteUseInSubClsInterface1 = extensionLoader.getExtension("concreteUseInSubClsInterface1");
    }

    public static void main(String[] args) {
        ExtensionLoader<UseInSubClsInterface> extensionLoader = ExtensionLoader
                .getExtensionLoader(UseInSubClsInterface.class);
        // 内部会自动调用injectExtension注入属性
        UseInSubClsInterface concreteUseInSubClsInterface1 = extensionLoader.getExtension("concreteUseInSubClsInterface1");
        System.out.println(concreteUseInSubClsInterface1);
    }
}
